package com.huishen.edrivenew.net;

import android.content.Context;
import android.os.Looper;

import com.huishen.edrivenew.AppManager;
import com.huishen.edrivenew.Constants;
import com.huishen.edrivenew.util.TLog;
import com.loopj.android.http.AsyncHttpResponseHandler;

import org.apache.http.Header;

import java.io.ByteArrayInputStream;

/**
 * 网络回调处理
 * @author wu
 * @version 1.0
 * @created 2015/7/2
 */
public class OperationResponseHandler extends AsyncHttpResponseHandler {

    private Object[] args;
    Context context;

    public OperationResponseHandler(Looper looper, Object... args) {
        super(looper);
        this.args = args;
    }

    public OperationResponseHandler(Object... args) {
        this.args = args;
    }


    @Override
    public void onSuccess(int code, Header[] headers, byte[] bytes) {

    }

    @Override
    public void onFailure(int i, Header[] headers, byte[] bytes, Throwable throwable) {
        onFailure(i, throwable.getMessage(), args);
        if(i == Constants.N_OUTH_ERROR) {
            AppManager.getInstance().logout(context);
        }
    }




    public void onSuccess(int code, ByteArrayInputStream is, Object[] args) {
        TLog.log("OperationSoapResponseHandler" + code + "  success");
    }

    public void onFailure(int code, String errorMessage, Object[] args) {
        TLog.log("OperationSoapResponseHandler" + code + "  " + errorMessage);
    }

    
    
    public void setContext(Context context) {
        this.context = context;
    }


}
